<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Title</title>
</head>
<body>
<script>
  function  add(){
    let args = [...arguments]
    let fn = function  () {
      args.push(...arguments)
      return fn
    }
    fn.toString = function () {
      console.log(1);
      return args.reduce((x,y) => x+y)
    }
    return fn
  }

  console.log(add(1)(2)(3));
</script>
</body>
</html>